const path = require("path");
const { name } = require("./package");

function resolve(dir) {
  return path.join(__dirname, dir);
}

const port = 8081; // dev port

module.exports = {
  lintOnSave: false,
  outputDir: "dist",
  assetsDir: "static",
  filenameHashing: true,
  publicPath: process.env.NODE_ENV === "production" ? "" : "//localhost:8081", // 开发环境设置为当前固定访问地址
  devServer: {
    // host: '0.0.0.0',
    hot: true,
    // disableHostCheck: false,
    port,
    client: {
      overlay: {
        warnings: false,
        errors: true,
      },
    },
    // 跨域
    headers: {
      "Access-Control-Allow-Origin": "*",
    },
  },
  // 自定义webpack配置
  configureWebpack: {
    resolve: {
      alias: {
        "@": resolve("src"),
      },
    },
    output: {
      // 把子应用打包成 umd 库格式(必须)
      library: `${name}-[name]`,
      libraryTarget: "umd",
      chunkLoadingGlobal: `webpackJsonp_${name}`,
    },
  },
};
